{% extends 'core/base.html' %}
{% load static %}

{% block title %}举报信息管理 - 社区管理系统{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h2>
                    <i class="fas fa-flag text-danger"></i>
                    举报信息管理
                </h2>
                <a href="{% url 'create_report' %}" class="btn btn-primary">
                    <i class="fas fa-plus"></i> 新增举报
                </a>
            </div>
        </div>
    </div>

    <!-- 搜索和筛选 -->
    <div class="row mb-4">
        <div class="col-md-6">
            <form method="GET" class="d-flex">
                <input type="text" class="form-control" name="search" placeholder="搜索举报类型或原因..." value="{{ search_query }}">
                <button type="submit" class="btn btn-outline-secondary ms-2">
                    <i class="fas fa-search"></i>
                </button>
            </form>
        </div>
    </div>

    <!-- 举报列表 -->
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead class="thead-light">
                                <tr>
                                    <th>ID</th>
                                    <th>举报类型</th>
                                    <th>举报人</th>
                                    <th>举报原因</th>
                                    <th>举报时间</th>
                                    <th>视频数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for report in page_obj %}
                                <tr>
                                    <td>{{ report.report_id }}</td>
                                    <td>
                                        <span class="badge badge-warning">{{ report.report_type }}</span>
                                    </td>
                                    <td>{{ report.reporter.username }}</td>
                                    <td>{{ report.reason|truncatechars:50 }}</td>
                                    <td>{{ report.created_at|date:"Y-m-d H:i:s" }}</td>
                                    <td>
                                        <span class="badge badge-info">{{ report.reportvideo_set.count }}</span>
                                    </td>
                                    <td>
                                        <a href="{% url 'report_detail' report.report_id %}" class="btn btn-sm btn-outline-primary">
                                            <i class="fas fa-eye"></i> 查看
                                        </a>
                                    </td>
                                </tr>
                                {% empty %}
                                <tr>
                                    <td colspan="7" class="text-center text-muted py-4">
                                        <i class="fas fa-inbox fa-2x mb-2"></i>
                                        <p>暂无举报信息</p>
                                    </td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 分页 -->
    {% if page_obj.has_other_pages %}
    <div class="row mt-4">
        <div class="col-12">
            <nav aria-label="举报信息分页">
                <ul class="pagination justify-content-center">
                    {% if page_obj.has_previous %}
                    <li class="page-item">
                        <a class="page-link" href="?page=1">首页</a>
                    </li>
                    <li class="page-item">
                        <a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a>
                    </li>
                    {% endif %}
                    
                    <li class="page-item active">
                        <span class="page-link">{{ page_obj.number }} / {{ page_obj.paginator.num_pages }}</span>
                    </li>
                    
                    {% if page_obj.has_next %}
                    <li class="page-item">
                        <a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a>
                    </li>
                    <li class="page-item">
                        <a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">末页</a>
                    </li>
                    {% endif %}
                </ul>
            </nav>
        </div>
    </div>
    {% endif %}
</div>
{% endblock %}
